﻿using System;
using System.Runtime.InteropServices;
using UnityEngine;

[Serializable, StructLayout(LayoutKind.Sequential)]
public struct SerializableVector3
{
    public float x;
    public float y;
    public float z;
    public SerializableVector3(Vector3 value)
    {
        this.x = value.x;
        this.y = value.y;
        this.z = value.z;
    }

    public override string ToString()
    {
        return string.Format("(X:{0:G} Y:{1:G} Z:{2:G})", this.x, this.y, this.z);
    }

    public static implicit operator Vector3(SerializableVector3 value)
    {
        return new Vector3(value.x, value.y, value.z);
    }

    public static implicit operator SerializableVector3(Vector3 value)
    {
        return new SerializableVector3(value);
    }

    public static implicit operator string(SerializableVector3 value)
    {
        return value.ToString();
    }
}

